import java.io.*;

class MyBufferedInputStream
{
	private InputStream in;

	private byte[] buf = new byte[1024*4];

	private int pos = 0;
	private int len = 0;

	MyBufferedInputStream(InputStream in)
	{
		this.in = in;
	}

	public int myRead()throws IOException
	{
		if(len==0)
		{
			len = in.read(buf);
			if(len<0)
				return -1;
			
			pos=0;
			byte b = buf[pos];

			//System.out.println("b="+b);
			pos++;
			len--;
			return b&0xff;
		}
		else if( len>0)
		{
			byte b = buf[pos];
			pos++;
			len--;
			return b&255;
		}
		return -1;

	}
	public void myClose()throws IOException
	{
		in.close();
	}
}